// pages/list/list.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    swiperList:[
      {
        imageSrc:"/img/商品详情页/detail-1.png",
      url:"/pages/goods-detail/goods-detail",
      pinming:"黑巧慕斯星冰乐"
    },
    {
      imageSrc:"/img/商品详情页/detail-2.png",
      url:"/pages/goods-detail/goods-detail",
      pinming:"草莓轻乳酪星冰乐"
    },
    {
      imageSrc:"/img/分类/fenlei-1.png",
      url:"/pages/goods-detail/goods-detail",
      pinming:"红茶拿铁"
    },
    {
      imageSrc:"/img/分类/fenlei-2.png",
      url:"/pages/goods-detail/goods-detail",
      pinming:"焦糖玛奇朵"
    },
    {
      imageSrc:"/img/分类/fenlei-3.png",
      url:"/pages/goods-detail/goods-detail",
      pinming:"美式咖啡"
    },
    {
      imageSrc:"/img/分类/fenlei-3.png",
      url:"/pages/goods-detail/goods-detail",
      pinming:"拿铁"
    },
    
    ],
    left_name:[{id:0,name:'咖啡',url:"/pages/goods-list/goods-list"},
    {id:1,name:'奶茶'},
    {id:2,name:'茶水'},
    {id:3,name:'蛋糕'},
    {id:4,name:'冰淇淋'},
    ],
    all:[],
    product:[],
    id:0,
    num:0,
    name:'',
  },

  // 显示对应分类的商品
  selectId(res){
    var that = this;
    var name = res.currentTarget.dataset.name;
    var name_1 = '';
    var array = [];
    console.log(name);
    that.setData({
      name:name
    })
    // for(var i = 0; i < that.data.left_name.length;i++){
    //   if(that.data.left_name[i].name == name){
    //     console.log("当前选择的分类是",that.data.left_name[i].name)
    //     name_1 = that.data.left_name[i].name;
    //   }
    // }
    for(var j = 0; j < that.data.all.length; j++){
      if(that.data.all[j].fenlei == name){
        array.push(that.data.all[j]);
      }
    }
    that.setData({
      product:array
    })
    console.log(that.data.product)
  },
  /**
   * 生命周期函数--监听页面加载
   */
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})